﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace msBsc.WebUi.wMall.Public
{
    public partial class wfTravelIndex : msBsc.Cls.BPage
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        private void getArea2(string parentsId)
        {
            using (msBsc.AppLogic.DataAlc.CBizCountryCity cbcc = new AppLogic.DataAlc.CBizCountryCity())
            {
                DataSet ds = cbcc.SelectCountryByParentId(parentsId);
                if (ds == null || ds.Tables[0].Rows.Count < 1)
                {
                    return;
                }
                string cityId = this.GetParamHtValue("cityId");
                string ret = msBsc.AppLogic.Cfg.HttpTools.GetJsonByTable(ds.Tables[0], "", "", 1, 1000, "");
                if (string.IsNullOrEmpty(cityId))
                {
                    cityId = ds.Tables[0].Rows[0]["COUNTRY_CITY_ID"].ToString();
                }
                this.ExecJScript(@"updateSelet(""cityId_select""," + ret + @",""" + cityId + @""")");
                getArea3(cityId);
            }
        }
        private void getArea3(string parentsId)
        {
            using (msBsc.AppLogic.DataAlc.CBizCountryCity cbcc = new AppLogic.DataAlc.CBizCountryCity())
            {
                DataSet ds = cbcc.SelectCountryByParentId(parentsId);
                if (ds == null || ds.Tables[0].Rows.Count < 1)
                {
                    return;
                }
                string isAll = this.GetParamHtValue("isAll");
                if (isAll.ToLower() == "true")
                {
                    DataRow dr = ds.Tables[0].NewRow();
                    dr["COUNTRY_CITY_ID"] = "";
                    dr["COUNTRY_CITY_NME"] = "全部";
                    ds.Tables[0].Rows.InsertAt(dr, 0);
                }
                string ret = msBsc.AppLogic.Cfg.HttpTools.GetJsonByTable(ds.Tables[0], "", "", 1, 1000, "");
                string destionId = this.GetParamHtValue("destionId");
                if (string.IsNullOrEmpty(destionId))
                {
                    destionId = ds.Tables[0].Rows[0]["COUNTRY_CITY_ID"].ToString();
                }
                this.ExecJScript(@"updateSelet(""destionId_select""," + ret + @",""" + destionId + @""")");

            }
        }
        private void initplace(string parentsId)
        {
            using (msBsc.AppLogic.DataAlc.CBizCountryCity cbcc = new AppLogic.DataAlc.CBizCountryCity())
            {
                DataSet ds = cbcc.SelectCountryByParentId(parentsId);
                if (ds == null || ds.Tables[0].Rows.Count < 1)
                {
                    return;
                }
                string countryId = this.GetParamHtValue("countryId");
                if (string.IsNullOrEmpty(countryId))
                {
                    countryId = ds.Tables[0].Rows[0]["COUNTRY_CITY_ID"].ToString();
                }
                string ret = msBsc.AppLogic.Cfg.HttpTools.GetJsonByTable(ds.Tables[0], "", "", 1, 1000, "");
                this.ExecJScript(@"updateSelet(""countryId_select""," + ret + @",""" + countryId + @""")");
                getArea2(countryId);
            }
        }

        private void GetClassicScenic()
        {
            using (msBsc.AppLogic.DataAlc.CBizPushScenic scenic = new AppLogic.DataAlc.CBizPushScenic())
            {
                DataSet ds = scenic.GetScenicForPageview(6, 1, "", "", "");
                if (ds == null || ds.Tables[0].Rows.Count < 1)
                {
                    return;
                }
                string strJson = msBsc.AppLogic.Cfg.HttpTools.GetJsonByTable(ds.Tables[0], "", "", 1, 20, "");
                this.ExecJScript(@"
                            var _html = $('#svc_list_temp_scenic').html();
                            laytpl(_html).render(" + strJson.ToString() + @", function (render) {
                                $('#scenicList').html(render);
                            });");
            }
        }

        private void GetClassicFood()
        {
            using (msBsc.AppLogic.DataAlc.CBizPushNiceFood food = new AppLogic.DataAlc.CBizPushNiceFood())
            {
                DataSet ds = food.GetNiceFoodForPageview(6, 1, "", "", "");
                if (ds == null || ds.Tables[0].Rows.Count < 1)
                {
                    return;
                }
                string strJson = msBsc.AppLogic.Cfg.HttpTools.GetJsonByTable(ds.Tables[0], "", "", 1, 20, "");
                this.ExecJScript(@"
                                            var _html = $('#svc_list_tem_food').html();
                            laytpl(_html).render(" + strJson + @", function (render) {
                                                $('#foodList').html(render);
                            });");
            }
        }

        private void GetClassicSpecialty()
        {
            using (msBsc.AppLogic.DataAlc.CBizPushSpecialty specialty = new AppLogic.DataAlc.CBizPushSpecialty())
            {
                DataSet ds = specialty.GetSpecialForPageview(6, 1, "", "", "");
                if (ds == null || ds.Tables[0].Rows.Count < 1)
                {
                    return;
                }
                string strJson = msBsc.AppLogic.Cfg.HttpTools.GetJsonByTable(ds.Tables[0], "", "", 1, 20, "");
                this.ExecJScript(@"
                                            var _html = $('#svc_list_tem_specialty').html();
                                            laytpl(_html).render(" + strJson + @", function (render) {
                                                $('#specialtyList').html(render);
                                            });");
            }
        }

        public override void DoAction()
        {
            if (this.strAction == "init")
            {
                //DateTime dttem = System.DateTime.Now;
                //string parentsId = this.GetParamHtValue("parentsId");
                //initplace(parentsId);
                //string countryId = this.GetParamHtValue("countryId");
                //string cityId = this.GetParamHtValue("cityId");
                //string destionId = this.GetParamHtValue("destionId");
                GetClassicScenic();
                GetClassicFood();
                GetClassicSpecialty();
                base.DoAction();
            }
        }
    }
}